package com.service.impl;

import com.dao.ShopCartDao;
import com.dao.impl.ShopCartDaoImpl;
import com.pojo.ShopCart;
import com.pojo.Users;
import com.service.ShopCartService;

import java.util.UUID;

public class ShopCartServiceImpl implements ShopCartService {
    private ShopCartDao dao = new ShopCartDaoImpl();


    @Override
    public ShopCart findByUserID(String userID) {
        ShopCart shopCart = dao.selectByUserID(userID);
        if (shopCart==null){
            shopCart = new ShopCart();
            shopCart.setId(UUID.randomUUID().toString().replace("-","").substring(0,10));
            shopCart.setCartId(UUID.randomUUID().toString().replace("-","").substring(0,10));
            shopCart.setUserId(userID);
            dao.addShopCar(shopCart);
        }
        return shopCart;
    }

}
